package com.watson.voice.controller;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Description: TODO
 * @Author watson
 * @Date 2022/7/25 08:40
 * @Version 1.0
 */
public class ExecuteCmd {
    public static String executeCmd(String command) throws IOException {

        Runtime runtime = Runtime.getRuntime();
        Process process = runtime.exec("cmd /c " + command);
        BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "GBK"));
        String line = null;
        StringBuilder build = new StringBuilder();
        while ((line = br.readLine()) != null) {
            System.err.println(line);
            build.append(line);
        }
        return build.toString();
    }

    public static void main(String[] args) throws IOException {
        executeCmd("C:\\Users\\AdminWatson\\Desktop\\picture\\UGJ\\3.png");
    }
}
